MsgN("-- hooks.lua loaded")

function MDRP.PlayerInitialSpawn( ply )
	if (!MDRP.IsEnabled()) then return end
	ply:Load()
end
hook.Add("PlayerInitialSpawn", "MDRP.PlayerInitialSpawn", MDRP.PlayerInitialSpawn)

function MDRP.PlayerDisconnected( ply )
	if (!MDRP.IsEnabled()) then return end
	ply:Save()
end
hook.Add("PlayerDisconnected", "MDRP.PlayerDisconnected", MDRP.PlayerDisconnected)

function MDRP.PlayerSpawnProp( ply, mdl, ent )
	if (!MDRP.IsEnabled()) then return end

	--Admin only models
	if (!ply:IsAdmin()) and (IsModelMatch(mdl,MDRP.Seeds.Food) or IsModelMatch(mdl,MDRP.Seeds.Tree)) then
		ply:EasyMessage( "You cannot spawn this prop unless you're admin." )
		return false
	end

	if (ply.CanSpawnProp == false) then
		ply:EasyMessage( "You can not fast spawn props!" )
		return false
	end

	ply.CanSpawnProp = false

	--set timer to allow spawning of more props
	timer.Simple(0.8, function()
		ply.CanSpawnProp = true
	end)

	return true
end
hook.Add("PlayerSpawnProp", "MDRP.PlayerSpawnProp", MDRP.PlayerSpawnProp)

function MDRP.PhysgunPickup( ply, ent )
	if (!MDRP.IsEnabled()) then return end
	
	if (!ply:IsAdmin()) and (ent:IsRock() or ent:IsTree() or ent:IsPlayer()) then
		return false
	else
		return true
	end
end
hook.Add( "PhysgunPickup", "MDRP.PhysgunPickup", MDRP.PhysgunPickup )

function MDRP.GravGunPunt( ply, ent )
	if (!MDRP.IsEnabled()) then return end
	
	return ply:IsAdmin()
end
hook.Add( "GravGunPunt", "MDRP.GravGunPunt", MDRP.GravGunPunt )

function MDRP.CanTool( ply, tr, mode )
	if (!MDRP.IsEnabled()) then return end

	if (table.HasValue( MDRP.ProhibitedTools, mode )) then
		ply:EasyMessage( "This sTOOL is prohibited." )
		return false
	end

	local ent = tr.Entity

	if (mode == "remover") && (!ply:IsAdmin()) && (ent:IsFood() or ent:IsTree() or ent:IsRock()) then
		ply:EasyMessage( "This is prohibited!" )
		return false
	end

	return true
end
hook.Add( "CanTool", "MDRP.CanTool", MDRP.CanTool )


--[[
	Dont need for now
	
	
--one think function to do all needed stuff
function MDRP.Think()
	--exit if updating to soon
	if (CurTime() <= (MDRP.NextUpdateTime or 0)) then return end

	--1 second update period
	MDRP.NextUpdateTime = CurTime() + 1
end
hook.Add("Think", "MDRP.Think", MDRP.Think)
]]